#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "NamedElement.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class ConnectableElement;
class Interaction;
class InteractionFragment;
class PartDecomposition;
class ValueSpecification;

/// <summary>
/// Lifeline
/// A Lifeline represents an individual participant in the Interaction. While parts
/// and structural features may have multiplicity greater than 1, Lifelines
/// represent only one interacting entity.
/// </summary>
class UMLMODEL_EXPORT Lifeline : public NamedElement {

public: // Constructors and destructors
    explicit Lifeline(const QString& umlType="uml::Lifeline");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Properties
    /// <summary>
    /// coveredBys getter
    /// References the InteractionFragments in which this Lifeline takes part.
    /// </summary>
    vector<shared_ptr<InteractionFragment>>& coveredBys();

    /// <summary>
    /// decomposedAs getter
    /// References the Interaction that represents the decomposition.
    /// </summary>
    shared_ptr<PartDecomposition> decomposedAs() const;

    /// <summary>
    /// decomposedAs setter
    /// References the Interaction that represents the decomposition.
    /// </summary>
    void setDecomposedAs(shared_ptr<PartDecomposition> value);

    /// <summary>
    /// interaction getter
    /// References the Interaction enclosing this Lifeline.
    /// </summary>
    shared_ptr<Interaction> interaction() const;

    /// <summary>
    /// interaction setter
    /// References the Interaction enclosing this Lifeline.
    /// </summary>
    void setInteraction(shared_ptr<Interaction> value);

    /// <summary>
    /// represents getter
    /// References the ConnectableElement within the classifier that contains the
    /// enclosing interaction.
    /// </summary>
    shared_ptr<ConnectableElement> represents() const;

    /// <summary>
    /// represents setter
    /// References the ConnectableElement within the classifier that contains the
    /// enclosing interaction.
    /// </summary>
    void setRepresents(shared_ptr<ConnectableElement> value);

    /// <summary>
    /// selector getter
    /// If the referenced ConnectableElement is multivalued, then this specifies the
    /// specific individual part within that set.
    /// </summary>
    shared_ptr<ValueSpecification> selector() const;

    /// <summary>
    /// selector setter
    /// If the referenced ConnectableElement is multivalued, then this specifies the
    /// specific individual part within that set.
    /// </summary>
    void setSelector(shared_ptr<ValueSpecification> value);

private: // Fields
    /// <summary>
    /// coveredBys
    /// References the InteractionFragments in which this Lifeline takes part.
    /// </summary>
    vector<shared_ptr<InteractionFragment>> coveredBys_;

    /// <summary>
    /// decomposedAs
    /// References the Interaction that represents the decomposition.
    /// </summary>
    shared_ptr<PartDecomposition> decomposedAs_;

    /// <summary>
    /// interaction
    /// References the Interaction enclosing this Lifeline.
    /// </summary>
    shared_ptr<Interaction> interaction_;

    /// <summary>
    /// represents
    /// References the ConnectableElement within the classifier that contains the
    /// enclosing interaction.
    /// </summary>
    shared_ptr<ConnectableElement> represents_;

    /// <summary>
    /// selector
    /// If the referenced ConnectableElement is multivalued, then this specifies the
    /// specific individual part within that set.
    /// </summary>
    shared_ptr<ValueSpecification> selector_;

};

} // namespace uml
